<?php
/***
 *
 * Class: MiniappController //小程序交互控制器
 * Author: Jason ZHENG
 * Data: 2018-11-24
 *
 ***/
namespace App\Http\Controllers;

class MiniappController extends Controller {

	public function __construct() {

	}

	public function index() {
		return "Miniapp controller";
	}

	//EncodingAESKey:zWOcMgLrX4Y7qgEMEgjruE9ayiLBIFDfnjLXuPq1GDk
	public function checkSignature() {
		$signature = $_GET["signature"];
		$timestamp = $_GET["timestamp"];
		$nonce = $_GET["nonce"];

		$token = 'ruixiangxianshe';
		$tmpArr = array($token, $timestamp, $nonce);
		sort($tmpArr, SORT_STRING);
		$tmpStr = implode($tmpArr);
		$tmpStr = sha1($tmpStr);

		if ($tmpStr == $signature) {
			return true;
		} else {
			return false;
		}
	}
}